package com.ngmaster.socket;

import java.util.HashMap;
import java.util.Map;

/**
 * 命令类型
 * */
public enum CmdType {

    GainDeviceId((byte) 0x00, "获取设备ID", "", (short) 0x0004),
    HeartBeat((byte) 0x01, "心跳", "", (short) 0x0028),
    BindPricing((byte) 0x02, "绑定套餐", "", (short) 0x000B),
    ScreenClose((byte) 0x03, "关闭屏幕", "", (short) 0x0001),
    ScreenOpen((byte) 0x04, "打开屏幕", "", (short) 0x0001),
    Shutdown((byte) 0x05, "关机", "", (short) 0x0001),
    Startup((byte) 0x06, "开机", "", (short) 0x0001),
    ForceWash((byte) 0x07, "强冲", "", (short) 0x0001),
    AddMoney((byte) 0x08, "充正值", "", (short) 0x0002),
    SubMoney((byte) 0x09, "充负值", "", (short) 0x0002),
    SyncWater((byte) 0x0A, "用水同步", "", (short) 0x0002),
    SyncTime((byte) 0x0B, "用时同步", "", (short) 0x0002),
    SyncWorkStatus((byte) 0x0C, "工作状态同步", "", (short) 0x0001),
    QueryDeviceInfo((byte) 0x0D, "查询设备运行信息", "", (short) 0x0001),
    UpdateFilter((byte) 0x0E, "滤芯复位与修改", "", (short) 0x0003),
    SwitchBillModel((byte) 0x0F, "切换计费模式", "", (short) 0x0003),
    WipeData((byte) 0x10, "恢复出厂设置", "", (short) 0x0001),
    UpdateHostPort((byte) 0x11, "修改域名和端口号", "", (short) 0x0000),
    UpdateHeartbeatInterval((byte) 0x12, "修改心跳周期", "", (short) 0x0002),
    RWPumpWorkTime((byte)0x13, "时间租赁模式，时长记录应用参数", "", (short) 0x0002),
    RWWashTime((byte)0x14, "读取和修改冲洗时间，单位秒", "", (short) 0x0002),
    RWFixWashTime((byte)0x15, "读取和修改定时冲洗时间，单位分钟", "", (short) 0x0002),
    RWServiceTime((byte)0x16, "读取和修改检修时间，单位分钟", "", (short) 0x0002),
    RWReWashTime((byte)0x17, "读取和修改两次水满制水超过1分钟,再次水满冲洗时间", "", (short) 0x0002),
    ReadIccid((byte)0x18, "从设备读取或设备上报ICCID", "", (short) 0x000A),
    OneWaterOfTime((byte)0x19, "制1升水需要的时间", "", (short) 0x0002),
    ;
    private final byte cmd;
    private final String intro;
    private final String des;
    /** 该协议可变数据长度 */
    private final short dataLength;
    private final static Map<Byte, CmdType> es = new HashMap<>();

    static {
        for (CmdType e : values()) {
            es.put(e.getCmd(), e);
        }
    }


    private CmdType(byte cmd, String intro, String des, short dataLength) {
        this.cmd = cmd;
        this.intro = intro;
        this.des = des;
        this.dataLength = dataLength;
    }

    public byte getCmd() {
        return cmd;
    }

    public String getIntro() {
        return intro;
    }

    public String getDes() {
        return des;
    }

    public short getDataLength() {
        return dataLength;
    }

    public static final CmdType get(byte cmd) {
        return es.get(cmd);
    }
}
